package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.data.attribute.OptValue;
import org.akomantoso.core.data.group.ANtitleInline;
import org.akomantoso.core.io.Output;
import org.akomantoso.core.io.OutputUtil;
import org.akomantoso.core.visitor.AKVisitor;

/**
 * The element legislature is an inline element within preface to identify the string used by the document for the
 * legislature relative to the document. Use #refersTo to a TLCEvent to refer to the event of the specific legislature.
 * 
 * <pre>
 * 	<xsd:element name="legislature">
 * 		<xsd:complexType mixed="true">
 * 			<xsd:complexContent>
 * 				<xsd:extension base="inline">
 * 					<xsd:attributeGroup ref="optvalue"/>
 * 				</xsd:extension>
 * 			</xsd:complexContent>
 * 		</xsd:complexType>
 *	</xsd:element>
 * </pre>
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 * 
 * @since http://www.akomantoso.org/1.0
 */
public final class Legislature extends InlineType implements OptValue, ANtitleInline {

	public static final String ELEMENT = "legislature";

	private String _value;

	/**
	 * @see org.akomantoso.core.data.attribute.OptValue#getValue()
	 */
	@Override
	public String getValue() {
		return _value;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.OptValue#setValue(java.lang.String)
	 */
	@Override
	public void setValue(String value) {
		_value = value;
	}

	/**
	 * @see org.akomantoso.core.data.InlineType#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <E extends Output> void writeExternal(E out) throws IOException {
		out.writeStart(ELEMENT);
		OutputUtil.writeOptValue(out,this);
		super.writeExternal(out);
		out.writeEnd();
	}

	/**
	 * @see ec.ep.visitor.AKVisitable#accept(ec.ep.visitor.AKVisitor)
	 */
	public void accept(AKVisitor visitor) {
		if (visitor.visitBegin(this)) {
			internalAccept(visitor);
			visitor.visitEnd(this);
		}
	}

}